package odor;

import java.util.Random;

import util.Util;

public final class OdorPreprocessor 
{
	
	public static Odor[] generateSimilarOdors(int numOdors, int numMitrals)
	{
		Odor[] battery = new Odor[numOdors];
		battery[0] = createRandomOdor(numMitrals);
		
		Random r = new Random();
		
		for (int x=1; x<battery.length; x++)
		{
			Odor prev = battery[x-1];
			
			double inputs[] = prev.getInputs();
			
			for (int y=0; y<inputs.length; y++)
			{
				double scalar = 0;
				
				do
				{
					scalar = r.nextGaussian();
					
				}while(inputs[y] + scalar < 0);
				
				inputs[y] += scalar;
			}
			
			battery[x] = new Odor(inputs);
		}
		
		return battery;
	}
	
	public static Odor createRandomOdor(int numMitrals)
	{
		Odor od = null;
		double[] inputs = new double[numMitrals];
		
		for (int x=0; x<numMitrals; x++)
		{
			inputs[x] = Math.exp( -(Util.getPositiveGaussianValue()));
		}
		
		od = new Odor(inputs);
		
		return od;
	}
}
